Skip to content

Conversation

@conico974
Copy link
Contributor

This PR add test for #704
I've added a @ts-expect-error for the top level await, i didn't want to go down the rabbit hole of finding the issue here (middleware is somehow considered a cjs file and if set as a module, next/server import does not work anymore)
There is also a build time warning, but it still works both with next start or in the e2e test

@changeset-bot
Copy link

changeset-bot bot commented Jan 20, 2025

⚠️ No Changeset found

Latest commit: 67d0701

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

const topLevelAwait = await new Promise<string>((resolve) => {
setTimeout(() => {
resolve("top-level-await");
}, 150);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting - does it have to have a timeout? Would await Promise.resolve('top-level-await') work w/o the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily, it should work with Promise.resolve. I just wanted to emulate some wait time and be sure that we are not running on the same loop of the event loop.
We can probably make it 5 or 10 ms, no need for 150

@conico974 conico974 merged commit 9e770b5 into opennextjs:main Jan 21, 2025
1 check passed
@conico974 conico974 deleted the test/top-level-await-edge branch March 14, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants